<template>
    <div>
        <div v-if="bugList.length<1" style="text-align: center;font-weight: bolder;padding-top: 10px">您还没反馈过任何bug~</div>
        <div v-else
             style="display: flex;justify-content: space-between;align-items:center;height: 50px;border-bottom: 1px solid #f4f4f4"
             v-for="(item,index) in bugList"
             :key="index">
            <div style="margin-left: 4%">{{item.bugContent}}</div>
            <div style="margin-right: 4%">{{item.bugTime}}</div>
        </div>
        <!--分页-->
        <div style="margin-left: 3%;">
            <Page style="height: 30px;margin-top: 2%" :total="total" :page-size="bugVo.pageSize"
                  show-elevator show-sizer
                  show-total @on-change="changePageNum" :page-size-opts="pageSizeChoice"
                  @on-page-size-change="changePageSize"/>
        </div>
    </div>
</template>

<script>
  export default {
    data () {
      return {
        bugList: [],
        bugVo: {
          pageNum: 1,
          pageSize: 9,
          my: true
        },
        total: 0,
        pageSizeChoice: [9, 18, 30, 50, 100]
      }
    },
    mounted () {
      this.getBugs()
    },
    methods: {
      getBugs () {
        this.$http.get('bug', { params: new URLSearchParams(this.bugVo) }).then(res => {
          res = res.data
          if (res.code === 0) {
            this.bugList = res.data
            this.total = res.count
          } else {
            this.$Message.error(res.msg)
          }
        })
      },
      // 改变当前页码
      changePageNum (pagenum) {
        this.bugVo.pageNum = pagenum
        this.getBugs()
      },
      // 改变每页个数
      changePageSize (pagesize) {
        this.bugVo.pageSize = pagesize
        this.getBugs()
      }
    }
  }
</script>

<style scoped>

</style>
